#include "OptionsScreen.h"
#include "GameRules.h"
#include "ScreenManager.h"
#include "StartScreen.h"

OptionsScreen::OptionsScreen(void)
{
	menu.AddMenuItem(L"Muliples");
	menu.AddMenuItem(L"Factors");
	menu.AddMenuItem(L"Primes");
	menu.AddMenuItem(L"Back");
}

OptionsScreen::~OptionsScreen(void)
{
}

void OptionsScreen::Draw()
{
	Screen::Draw(); // Call the super class

	menu.DrawMenu();
	

}

void OptionsScreen::Update(double frameTime)
{
	Screen::Update(frameTime);

	Controls * controls = Controls::Instance();

	BYTE pressedKey;

	pressedKey = controls->GetPressedKey();

	if ( pressedKey == DIK_SPACE || pressedKey == DIK_RETURN )
	{
		if( menu.GetSelectedItem().compare(L"Mutiples") == 0 )
		{
			GameRules::Instance()->SetGameType(MULTIPLES);
			ScreenManager::Instance()->ChangeScreen(new StartScreen());
		}
		else if( menu.GetSelectedItem().compare(L"Factors") == 0 )
		{
			GameRules::Instance()->SetGameType(FACTORS);
			ScreenManager::Instance()->ChangeScreen(new StartScreen());
		}
		else if ( menu.GetSelectedItem().compare(L"Back") == 0 )
		{
			ScreenManager::Instance()->ChangeScreen(new StartScreen());
		}
	}
	else if( pressedKey == DIK_UP )
	{
		menu.MoveUp();
	}
	else if( pressedKey == DIK_DOWN )
	{
		menu.MoveDown();
	}
}